-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delay interning errors to after validation #122684
Delay interning errors to after validation #122684
Conversation
Some changes occurred to the CTFE / Miri engine cc @rust-lang/miri |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for trying this! IMO it looks promising.
it's not much simpler than the other PR, because now we need to handle nested statics generated by interning.
It seems a lot simpler to me, now we can entirely avoid that extra "patch mutability" stage?
I'm still not sure whether validation should truly also be responsible for handling pointers that can't be "seen" by the type system; this needs a full recursive traversal after all -- a traversal that interning already performs. It's also conceptually no longer about "validating a value".
The alternative would be for interning to return a Result<(), DelayedInternError>
and for the queries to do something like
let intern_res = intern();
validate()?;
if let Err(intern_err) = intern_res {
intern_err.emit();
}
DelayedInternError
could have a panicking drop to make sure we catch cases where emit
is forgotten.
We can still have validation opportunistically check for dangling pointers to get nice errors (in raw pointers, and maybe inside unions by just scanning the provenance map) -- but we'd not have to do a full second recursive traversal of everything reachable by such hidden pointers.
tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr
Outdated
Show resolved
Hide resolved
|
||
error: encountered mutable pointer in final value of static | ||
--> $DIR/static-no-inner-mut.rs:13:1 | ||
| ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.v: encountered `UnsafeCell` in read-only memory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The obvious reaction to this will be "so why is that memory read-only"...
c7b86c3
to
8f21f22
Compare
I removed all the untyped validation and will create a separate PR for it |
592f674
to
7517beb
Compare
Ah, good idea, thanks. |
.type_of(did) | ||
.no_bound_vars() | ||
.expect("statics should not have generic parameters") | ||
.is_freeze(*self.ecx.tcx, ty::ParamEnv::reveal_all()) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is pre-existing, but... why is reveal_all
okay here? Shouldn't this be ecx.param_env()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're asking for information about a static item's type. If anything we should get the param env of the static (but we know that is just ParamEnv::reveal_all()
anyway.
☔ The latest upstream changes (presumably #111769) made this pull request unmergeable. Please resolve the merge conflicts. |
@rustbot author |
7517beb
to
6290e5f
Compare
The new state is effectively a full rewrite. So I rebased, split it up into two commits and force pushed. |
@rustbot author |
@rustbot ready |
☔ The latest upstream changes (presumably #123385) made this pull request unmergeable. Please resolve the merge conflicts. |
35bea5a
to
2d936b4
Compare
@rustbot author |
No worries. I got enough stuff to do 😆 |
This comment has been minimized.
This comment has been minimized.
586145a
to
acb817a
Compare
This comment has been minimized.
This comment has been minimized.
acb817a
to
a3d987f
Compare
All my comments are resolved, r=me with or without some commit squashing. |
validation produces much higher quality errors and already handles most of the cases
a3d987f
to
126dcc6
Compare
@bors r=RalfJung |
…after_validaiton, r=RalfJung Delay interning errors to after validation fixes rust-lang#122398 fixes rust-lang#122548 This improves diagnostics since validation errors are usually more helpful compared with interning errors that just make broad statements about the entire constant r? `@RalfJung`
☀️ Test successful - checks-actions |
Finished benchmarking commit (5260893): comparison URL. Overall result: ❌ regressions - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)This benchmark run did not return any relevant results for this metric. CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 676.169s -> 679.408s (0.48%) |
fixes #122398
fixes #122548
This improves diagnostics since validation errors are usually more helpful compared with interning errors that just make broad statements about the entire constant
r? @RalfJung